package com.jkozniewski.math
{
	public class MathUtil {
		
		public static function getPercentWithinRange(maxVal:Number, minVal:Number, value:Number) : Number {
			return (value - minVal)/(maxVal - minVal) * 100;
		}
		
		public static function trim( max:Number, min:Number, val:Number ) : Number {
			return Math.min( Math.max( min, val ), max );
		}
		
		public static function roundN(n:Number,m:Number) : Number {
			return Math.round((n*Math.pow(10,m)))/Math.pow(10,m);
		}
		
		public static function isEven(n:Number) : Boolean {
			return ((n & 1) == 0);
		}
		
		public static function randomRange(minVal, maxVal) : Number {
			return minVal + Math.floor(Math.random()*(maxVal+1 - minVal));
		}
		
		public static function randomRangeFloat(minVal, maxVal) : Number {
			return minVal + Math.random()*(maxVal - minVal);
		}
		
		public static function gaussian( x, a, b, c ) : Number {
			return a * Math.exp( -( ((x-b)*(x-b)) / (2*c*c)) );
		}
		
		
		

		
	}
}